const twoSum = function (nums: Array<number>, targte: number) {
  const map = new Map();
  const len = nums.length;
  for (let index = 0; index < len; index++) {
    const valI = nums[index];
    if (map.get(targte - valI) != undefined) {
      return [map.get(targte - valI), index];
    }
    map.set(valI, index);
  }
};

const nums = [2, 7, 11, 15];
const target = 9;
console.log(twoSum(nums, 9));
